#ifndef GLWIDGET_H
#define GLWIDGET_H

#include "src/scene.h"

#include <QGLWidget>
#include <QMouseEvent>
#include <QFile>

class GLWidget : public QGLWidget {
	Q_OBJECT

    public:
        GLWidget(QWidget* = 0);
        ~GLWidget();

        QSize minimumSizeHint() const;
        QSize sizeHint() const;
        void wheelEvent(QWheelEvent *);
        void mousePressEvent(QMouseEvent *);
        void mouseMoveEvent(QMouseEvent *);

        Scene *newScene();
        Scene *getScene();
//        std::vector<Object *> loadScene(QFile *);
//        Object *loadObject(QFile *);
//        void saveScene(QFile *);
//        void saveObject(QFile *);

        bool isShowingFace(){return showFace;};
        bool isShowingEdge(){return showEdge;};
        bool isShowingVertex(){return showVertex;};

    public slots:
        void setXRotation(int);
        void setYRotation(int);
        void setZRotation(int);

        void changeShowAxis(bool);
        void changeShowGrid(bool);
        void changeShowFace(bool _b){showFace = _b; updateGL();};
        void changeShowEdge(bool _b){showEdge = _b; updateGL();};
        void changeShowVertex(bool _b){showVertex = _b; updateGL();};
        void changeShowNormal(bool _b){showNormal = _b; updateGL();};

    private:
        void initializeGL(void);
        void paintGL(void);
        void resizeGL(int, int);

        void normalizeAngle(int *);

        double zoom;
        double xMov;
        double yMov;
        double zMov;
        int xRot;
        int yRot;
        int zRot;
        QPoint lastPos;

        bool showGrid;
        bool showAxis;
        bool showFace;
        bool showEdge;
        bool showVertex;
        bool showNormal;

        GLfloat light0_pos[4];
        GLfloat light0_ambient[4];
        GLfloat light0_diffuse[4];
        GLfloat light0_specular[4];
        GLfloat global_ambient[4];

        Scene *scene;
};

#endif


